#include <vector>
#include "assert.h"

#include "tokenizer.h"

#pragma once

using namespace std;

class SyntacticTreeNodeBase {
public:
	virtual ~SyntacticTreeNodeBase() {}
	virtual double Calculate() const = 0;
};

class BinaryOperatorNode : public SyntacticTreeNodeBase {
public:
	BinaryOperatorNode(const Token& _token, SyntacticTreeNodeBase* _first, SyntacticTreeNodeBase* _second) : 
		token(_token), first(_first), second(_second) {}
	~BinaryOperatorNode()
	{
		delete first;
		delete second;
	}
	virtual double Calculate() const;

private:
	Token token;
	SyntacticTreeNodeBase* first;
	SyntacticTreeNodeBase* second;
};

class NumberNode : public SyntacticTreeNodeBase {
public:
	NumberNode(const Token& _token) : token(_token)
	{
		assert(token.Type == Token::TT_Number);
	}
	virtual double Calculate() const { return token.Value; }

private:
	Token token;
};
